package com.hqyj.itemsservice.controller;

import com.hqyj.itemsservice.domain.Catalog;
import com.hqyj.itemsservice.json.R;
import com.hqyj.itemsservice.service.CatalogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("catalog")
public class CatalogController {

    @Resource
    private CatalogService catalogService;

    @GetMapping("/")
    public R queryAllCatalog() {
        List<Catalog> catalogList = new ArrayList<Catalog>();

        try {
            catalogList = catalogService.queryAllCatalogs();
            return R.success("查询商品板块列表成功！", catalogList);
        } catch (Exception ex) {
            ex.printStackTrace();
            return R.error("程序出现异常！");
        }
    }
}
